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 @@ -22,11 +22,14 @@ public class Messages extends NLS
private static final String BUNDLE_NAME = "com.espressif.idf.launch.serial.ui.internal.messages"; //$NON-NLS-1$
public static String NewSerialFlashTargetWizard_Title;
public static String NewSerialFlashTargetWizardPage_Description;
public static String NewSerialFlashTargetWizardPage_EnableDetailedOutputCheckboxName;
public static String NewSerialFlashTargetWizardPage_Fetching;
public static String NewSerialFlashTargetWizardPage_IDFTarget;
public static String NewSerialFlashTargetWizardPage_IDFTargetToolTipMsg;
public static String NewSerialFlashTargetWizardPage_Name;
public static String NewSerialFlashTargetWizardPage_NoBoardsDetectedWarningMsg;
public static String NewSerialFlashTargetWizardPage_SerialPort;
public static String NewSerialFlashTargetWizardPage_TargetOutputGroupName;
public static String NewSerialFlashTargetWizardPage_Title;
public static String CMakeMainTab2_FlashComboLbl;
public static String CMakeMainTab2_Arguments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import com.espressif.idf.core.LaunchBarTargetConstants;
import com.espressif.idf.core.build.IDFLaunchConstants;
import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.core.util.StringUtil;

public class NewSerialFlashTargetWizard extends LaunchTargetWizard
Expand Down Expand Up @@ -71,6 +72,7 @@ public boolean performFinish()

wc.save();
storeLastUsedSerialPort();
storeDetailedOutputCheckboxStatus();

// adding the target later to trigger LaunchBarListener with proper wc attributes
Job job = new Job(Messages.AddingTargetJobName)
Expand All @@ -87,6 +89,22 @@ protected IStatus run(IProgressMonitor monitor)
return true;
}

private void storeDetailedOutputCheckboxStatus()
{
Preferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
preferences.putBoolean(NewSerialFlashTargetWizardPage.PREF_ENABLE_DETAILED_OUTPUT,
page.isOutputDetailedChecked());

try
{
preferences.flush();
}
catch (BackingStoreException e)
{
Logger.log(e);
}
}

private void setOpenOCDAdaptorLocation(ILaunchTargetWorkingCopy wc)
{
String usbLocation = page.getSelectedBoardUsbLocation();
Expand All @@ -113,7 +131,7 @@ private void storeLastUsedSerialPort()
}
catch (BackingStoreException e)
{
e.printStackTrace();
Logger.log(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.launchbar.core.target.ILaunchTarget;
Expand All @@ -41,6 +44,7 @@
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -83,6 +87,14 @@ public class NewSerialFlashTargetWizardPage extends WizardPage
private Combo fFlashVoltage;
private String previousBoard = null;

protected boolean isOutputDetailed;
public static final String PREF_ENABLE_DETAILED_OUTPUT = Activator.PLUGIN_ID + ".enableDetailedOutput"; //$NON-NLS-1$

public boolean isOutputDetailedChecked()
{
return isOutputDetailed;
}

public NewSerialFlashTargetWizardPage(ILaunchTarget launchTarget)
{
super(NewSerialFlashTargetWizardPage.class.getName());
Expand Down Expand Up @@ -175,8 +187,13 @@ public void widgetSelected(SelectionEvent e)
}
display.asyncExec(() -> {
fBoardCombo.setItems(boardDisplayNames.toArray(new String[0]));
if (boardDisplayNames.isEmpty())
setMessage(Messages.NewSerialFlashTargetWizardPage_NoBoardsDetectedWarningMsg,
IMessageProvider.WARNING);

if (!boardDisplayNames.isEmpty())
{
setMessage(null);
int defaultIdx = 0;
if (jsonHolder[0] == null)
{
Expand Down Expand Up @@ -265,12 +282,38 @@ public void widgetSelected(SelectionEvent e)
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
Messages.NewSerialFlashTargetWizardPage_Fetching, e));
}
createInfoAreaGroup(comp);
setDefaults();
}

private void createInfoAreaGroup(Composite parentComp)
{
Group infoAreaGroup = new Group(parentComp, SWT.BORDER);
infoAreaGroup.setText(Messages.NewSerialFlashTargetWizardPage_TargetOutputGroupName);
infoAreaGroup.setLayout(new GridLayout(1, false));
infoAreaGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

Button detailedOutputCheckbox = new Button(infoAreaGroup, SWT.CHECK);
detailedOutputCheckbox.setText(Messages.NewSerialFlashTargetWizardPage_EnableDetailedOutputCheckboxName);
detailedOutputCheckbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

infoArea = new Text(comp, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
GridData infoAreaGridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
isOutputDetailed = preferences.getBoolean(PREF_ENABLE_DETAILED_OUTPUT, false);
detailedOutputCheckbox.setSelection(isOutputDetailed);

infoArea = new Text(infoAreaGroup, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
GridData infoAreaGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
infoAreaGridData.heightHint = 100;
infoArea.setLayoutData(infoAreaGridData);
setDefaults();

detailedOutputCheckbox.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
isOutputDetailed = detailedOutputCheckbox.getSelection();
}
});
}

/**
Expand Down Expand Up @@ -332,7 +375,7 @@ private void setDefaultTargetAndBoard()

private void setDefaultSerialPort()
{
if (serialPortCombo.getItemCount() < 0 || launchTarget == null)
if (serialPortCombo.getItemCount() == 0 || launchTarget == null)
{
return;
}
Expand Down Expand Up @@ -501,23 +544,33 @@ protected IStatus run(IProgressMonitor monitor)
String readLine;
while ((readLine = bufferedReader.readLine()) != null)
{
appendToInfoArea("."); //$NON-NLS-1$
if (isOutputDetailed)
{
appendToInfoArea(readLine + System.lineSeparator());
}
else
{
appendToInfoArea("."); //$NON-NLS-1$
chipInfo.append(readLine).append(System.lineSeparator());
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
chipInfo.append(readLine);
chipInfo.append(System.lineSeparator());
}
String chipType = extractChipFromChipInfoOutput(chipInfo.toString());

if (StringUtil.isEmpty(chipType))
if (!isOutputDetailed)
{
appendToInfoArea(
System.lineSeparator() + String.format(Messages.TargetPortNotFoundMessage, serialPort));
}
else
{
appendToInfoArea(System.lineSeparator()
+ String.format(Messages.TargetPortFoundMessage, serialPort, chipType));
if (StringUtil.isEmpty(chipType))
{
appendToInfoArea(
System.lineSeparator() + String.format(Messages.TargetPortNotFoundMessage, serialPort));
}
else
{
appendToInfoArea(System.lineSeparator()
+ String.format(Messages.TargetPortFoundMessage, serialPort, chipType));
}
}

}
catch (Exception e)
{
Expand Down Expand Up @@ -576,5 +629,4 @@ private List<String> getBoardDisplayNamesForTarget(String selectedTarget, JSONAr
}
return boardDisplayNames;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
################################################################################
NewSerialFlashTargetWizard_Title=New ESP Target
NewSerialFlashTargetWizardPage_Description=Enter name and properties for the target.
NewSerialFlashTargetWizardPage_EnableDetailedOutputCheckboxName=Enable detailed output
NewSerialFlashTargetWizardPage_Fetching=Fetching serial ports
NewSerialFlashTargetWizardPage_IDFTarget=IDF Target
NewSerialFlashTargetWizardPage_IDFTargetToolTipMsg=This will be configured as IDF_TARGET during the build process
NewSerialFlashTargetWizardPage_Name=Name:
NewSerialFlashTargetWizardPage_NoBoardsDetectedWarningMsg=No boards detected. Please check your connection or select a different target.
NewSerialFlashTargetWizardPage_SerialPort=Serial Port:
NewSerialFlashTargetWizardPage_TargetOutputGroupName=Target Detection Output
NewSerialFlashTargetWizardPage_Title=ESP Target
CMakeMainTab2_FlashComboLbl=Flash over:
CMakeMainTab2_Arguments=Arguments:
Expand Down
Loading