Skip to content

Commit b929cf1

Browse files
authored
IEP-1037: Fix for the confserver handling of the hex values (#859)
* IEP-1037: Fix for the confserver handling of the hex values * added hex tag to the label for hex values
1 parent cce5b99 commit b929cf1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bundles/com.espressif.idf.sdk.config.ui/src/com/espressif/idf/sdk/config/ui/SDKConfigurationEditor.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ protected void renderMenuItems(KConfigMenuItem selectedElement)
626626
else if (isVisible && type.equals(IJsonServerConfig.HEX_TYPE))
627627
{
628628
Label labelName = new Label(updateUIComposite, SWT.NONE);
629-
labelName.setText(kConfigMenuItem.getTitle());
629+
labelName.setText(kConfigMenuItem.getTitle().concat(" (hex)"));
630630

631631
Text textControl = new Text(updateUIComposite, SWT.SINGLE | SWT.BORDER);
632632
GridData gridData = new GridData();
@@ -635,8 +635,10 @@ else if (isVisible && type.equals(IJsonServerConfig.HEX_TYPE))
635635
textControl.setToolTipText(helpInfo);
636636
if (configValue != null)
637637
{
638-
textControl.setText(newConfigValue != null ? Long.toString((long) newConfigValue)
639-
: Long.toString((long) configValue));
638+
String hexText = newConfigValue != null ? Long.toHexString((long) newConfigValue)
639+
: Long.toHexString((long) configValue);
640+
textControl.setText("0x" + hexText.toUpperCase());
641+
640642
}
641643
textControl.addModifyListener(addModifyListener(configKey, textControl));
642644
addTooltipImage(kConfigMenuItem);
@@ -851,9 +853,11 @@ protected ModifyListener addModifyListener(String configKey, Text textControl)
851853
@Override
852854
public void modifyText(ModifyEvent e)
853855
{
856+
String text = textControl.getText().toLowerCase();
857+
boolean isHex = text.startsWith("0x");
854858
isDirty = true;
855859
editorDirtyStateChanged();
856-
modifiedJsonMap.put(configKey, textControl.getText().trim());
860+
modifiedJsonMap.put(configKey, isHex ? Long.parseLong(text.substring(2), 16) : textControl.getText().trim());
857861
}
858862
};
859863
}

0 commit comments

Comments
 (0)