Skip to content
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

feat: improving UX during run/debug #900

Merged
merged 3 commits into from
Mar 6, 2024
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
15 changes: 15 additions & 0 deletions bundles/com.espressif.idf.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,21 @@
</iterate>
</with>
</activeWhen>
</handler>
<handler
class="com.espressif.idf.ui.handlers.RunActionHandler"
commandId="org.eclipse.launchbar.ui.command.launchActive">
<activeWhen>
<with
variable="activeContexts">
<iterate
operator="or">
<equals
value="com.espressif.idf.ui.espLaunchScope">
</equals>
</iterate>
</with>
</activeWhen>
</handler>
</extension>
<extension point="org.eclipse.ui.preferencePages">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@Override
public void activeLaunchTargetChanged(ILaunchTarget target)
{
Display.getDefault().asyncExec(() -> {
Display.getDefault().syncExec(() -> {
if (target != null)
{
String targetName = target.getAttribute("com.espressif.idf.launch.serial.core.idfTarget", //$NON-NLS-1$
Expand Down Expand Up @@ -209,7 +209,7 @@
NLS.bind("Deleting {0} status...{1}", sdkconfigOld.getAbsolutePath(), sdkconfigOld.delete())); //$NON-NLS-1$

// attempting one more time!
sdkconfig.renameTo(sdkconfigOld);

Check warning on line 212 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/LaunchBarListener.java

View workflow job for this annotation

GitHub Actions / spotbugs

RV_RETURN_VALUE_IGNORED_BAD_PRACTICE

Exceptional return value of java.io.File.renameTo(File) ignored in com.espressif.idf.ui.LaunchBarListener.cleanSdkConfig(IResource)
Raw output
This method returns a value that is not checked. The return value should be checked since it can indicate an unusual or unexpected function execution. For example, the File.delete() method returns false if the file could not be successfully deleted (rather than throwing an Exception). If you don't check the result, you won't notice if the method invocation signals unexpected behavior by returning an atypical return value.
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public class Messages extends NLS
public static String HintDetailsTitle;
public static String FilterMessage;
public static String HintsYmlNotFoundErrMsg;
public static String SelectDebugConfigDialog_LableText;
public static String SelectDebugConfigDialog_Text;
public static String SelectDebugConfigDialog_Title;
public static String SelectLaunchConfigDialog_LableText;
public static String SelectLaunchConfigDialog_Text;
public static String SelectLaunchConfigDialog_Title;
public static String WriteFlashDialog_Bin_Path_Lbl;
public static String WriteFlashDialog_BinFileErrFormatErrMsg;
public static String WriteFlashDialog_Browse_Btn;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*******************************************************************************
* Copyright 2024-2025 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.ui.dialogs;

import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.ui.UIPlugin;

public class SelectDebugConfigDialog extends TitleAreaDialog
{

private Combo descriptorsCombo;
private final List<String> suitableConfiguratios;

public SelectDebugConfigDialog(Shell parentShell, List<String> suitableConfiguratios)
{
super(parentShell);
this.suitableConfiguratios = suitableConfiguratios;

Check warning on line 38 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/SelectDebugConfigDialog.java

View workflow job for this annotation

GitHub Actions / spotbugs

EI_EXPOSE_REP2

new com.espressif.idf.ui.dialogs.SelectDebugConfigDialog(Shell, List) may expose internal representation by storing an externally mutable object into SelectDebugConfigDialog.suitableConfiguratios
Raw output
This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
}

@Override
public void create()
{
super.create();
setTitle(Messages.SelectDebugConfigDialog_Title);
setMessage(Messages.SelectDebugConfigDialog_Text, IMessageProvider.INFORMATION);
}

@Override
protected void configureShell(Shell newShell)
{
super.configureShell(newShell);
newShell.setText(Messages.SelectDebugConfigDialog_Title);
}

@Override
protected void createButtonsForButtonBar(Composite parent)
{
// create OK and Cancel buttons by default
createButton(parent, IDialogConstants.OK_ID, "Debug", true); //$NON-NLS-1$
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

@Override
protected Control createDialogArea(Composite parent)
{
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout(2, false);
container.setLayout(layout);

Label descriptorsLabel = new Label(container, SWT.NONE);
descriptorsLabel.setText(Messages.SelectDebugConfigDialog_LableText);

GridData comboLayoutData = new GridData();
comboLayoutData.grabExcessHorizontalSpace = true;
comboLayoutData.horizontalAlignment = GridData.FILL;
comboLayoutData.horizontalSpan = 1;

descriptorsCombo = new Combo(container, SWT.READ_ONLY);
descriptorsCombo.setItems(suitableConfiguratios.toArray(new String[0]));
descriptorsCombo.select(0);
descriptorsCombo.setLayoutData(comboLayoutData);
return super.createDialogArea(parent);
}

@Override
protected void okPressed()
{
ILaunchBarManager launchBarManager = UIPlugin.getService(ILaunchBarManager.class);
try
{
ILaunchDescriptor[] descriptors = launchBarManager.getLaunchDescriptors();
Optional<ILaunchDescriptor> optDisc = Stream.of(descriptors)
.filter(disc -> disc.getName().contentEquals(descriptorsCombo.getText())).findFirst();
if (optDisc.isPresent())
{
launchBarManager.setActiveLaunchDescriptor(optDisc.get());
}

}
catch (CoreException e)
{
Logger.log(e);
}

super.okPressed();
}

}
sigmaaa marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*******************************************************************************
* Copyright 2024-2025 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.ui.dialogs;

import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.ui.UIPlugin;

public class SelectLaunchConfigDialog extends TitleAreaDialog
{
private Combo descriptorsCombo;
private final List<String> suitableConfiguratios;

public SelectLaunchConfigDialog(Shell parentShell, List<String> suitableConfiguratios)
{
super(parentShell);
this.suitableConfiguratios = suitableConfiguratios;

Check warning on line 37 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/SelectLaunchConfigDialog.java

View workflow job for this annotation

GitHub Actions / spotbugs

EI_EXPOSE_REP2

new com.espressif.idf.ui.dialogs.SelectLaunchConfigDialog(Shell, List) may expose internal representation by storing an externally mutable object into SelectLaunchConfigDialog.suitableConfiguratios
Raw output
This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
}

@Override
protected void configureShell(Shell newShell)
{
super.configureShell(newShell);
newShell.setText(Messages.SelectLaunchConfigDialog_Title);
}

@Override
public void create()
{
super.create();
setTitle(Messages.SelectLaunchConfigDialog_Title);
setMessage(Messages.SelectLaunchConfigDialog_Text, IMessageProvider.INFORMATION);
}

@Override
protected void createButtonsForButtonBar(Composite parent)
{
// create OK and Cancel buttons by default
createButton(parent, IDialogConstants.OK_ID, "Launch", true); //$NON-NLS-1$
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

@Override
protected Control createDialogArea(Composite parent)
{
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout(2, false);
container.setLayout(layout);

Label descriptorsLabel = new Label(container, SWT.NONE);
descriptorsLabel.setText(Messages.SelectLaunchConfigDialog_LableText);

GridData comboLayoutData = new GridData();
comboLayoutData.grabExcessHorizontalSpace = true;
comboLayoutData.horizontalAlignment = GridData.FILL;
comboLayoutData.horizontalSpan = 1;

descriptorsCombo = new Combo(container, SWT.READ_ONLY);
descriptorsCombo.setItems(suitableConfiguratios.toArray(new String[0]));
descriptorsCombo.select(0);
descriptorsCombo.setLayoutData(comboLayoutData);
return super.createDialogArea(parent);
}

@Override
protected void okPressed()
{
ILaunchBarManager launchBarManager = UIPlugin.getService(ILaunchBarManager.class);
try
{
ILaunchDescriptor[] descriptors = launchBarManager.getLaunchDescriptors();
Optional<ILaunchDescriptor> optDisc = Stream.of(descriptors)
.filter(disc -> disc.getName().contentEquals(descriptorsCombo.getText())).findFirst();
if (optDisc.isPresent())
{
launchBarManager.setActiveLaunchDescriptor(optDisc.get());
}

}
catch (CoreException e)
{
Logger.log(e);
}

super.okPressed();
}

}
sigmaaa marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ DeleteResourcesWizard_project_deleteConfigurations=Delete all related configurat
HintDetailsTitle=Hint Details
FilterMessage=type filter text
HintsYmlNotFoundErrMsg={0} is missing. Hints are only supported from esp-idf v5.0 and higher
SelectDebugConfigDialog_LableText=Suitable Debug Configurations:
SelectDebugConfigDialog_Text=To debug a project, the Debug Configuration should be selected. Select a Debug Configuration and click "Debug"
SelectDebugConfigDialog_Title=Select Debug Configuration
SelectLaunchConfigDialog_LableText=Suitable Launch Configurations:
SelectLaunchConfigDialog_Text=To launch a project, the Launch Configuration should be selected. Select a Launch Configuration and click "Launch"
SelectLaunchConfigDialog_Title=Select Launch Configuration
WriteFlashDialog_Bin_Path_Lbl=Bin Path:
WriteFlashDialog_BinFileErrFormatErrMsg=%s bin file doens't exist
WriteFlashDialog_Browse_Btn=Browse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class Messages extends NLS
public static String UpdateEspIdfCommand_JobMsg;
public static String UpdateEspIdfCommand_InstallToolsJobMsg;
public static String UpdateEspIdfCommand_SuggestToOpenInstallToolsWizard;
public static String MissingDebugConfigurationTitle;
public static String DebugConfigurationNotFoundMsg;

public static String RunActionHandler_NoProjectQuestionText;
public static String RunActionHandler_NoProjectQuestionTitle;

static
{
Expand Down
Loading
Loading